﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PSHelper : MonoBehaviour
{
    private ParticleSystem[] _particle;
    private float _deltaTime;
    private float _timeAtLastFrame;

    void Awake()
    {
        _particle = GetComponentsInChildren<ParticleSystem>(true);
    }

    void Update()
    {
        if (_particle.Length == 0) return;
        _deltaTime = Time.realtimeSinceStartup - _timeAtLastFrame;
        _timeAtLastFrame = Time.realtimeSinceStartup;
        foreach (var v in _particle)
        {
            if (Mathf.Abs(Time.timeScale) < 1e-6)
            {
                v.Simulate(_deltaTime, false, false);
                v.Play();
            }
        }
    }
}
